var salaryData;

function initial(){
    var datainfo = {
        "salarystandardid" : sessionStorage.salarystandardid1,
        "keyword" : sessionStorage.keyword1,
        "starttime" : sessionStorage.starttime1,
        "endtime" : sessionStorage.endtime1
    }
    /**
    JSON.stringify()是将JavaScript对象转换为json字符串
    JSON.parse(jsonstr)是将json字符串转换为javascript对象
    */
    $.ajax({
        /*url:"http://localhost/PersonManSystem/salary/no/book.action",*/
        url:"http://localhost/PersonManSystem/salary/like/query.action",
        type:"get",
        dataType:'json',
        data:datainfo,
        contentType:'application/json;charset=utf-8',
        success:function(data){
            salaryData = data;
            initSalaryLoadData(data);
            /*initSalaryLoadData(data, '2*/
        },
        error:function(XMLHttpRequest, textStatus, errorThrown){
            alert("Error");
            alert(XMLHttpRequest.status);
            alert(XMLHttpRequest.readyState);
            alert(textStatus);
        }
    });

}

/*初始化薪酬标准*/
function initSalaryLoadData(data){

        var salaryStandardNameSelect = $("#salarystandardname");
        $(data['data']).each(function(){
            salaryStandardNameSelect.append("<option value='" + this.salarystandardname + "'>" + this.salarystandardname + "</option>");
        });

        salarystandardnamewhenchange($("#salarystandardname").val());
}

// "salarystandardid": "10000001000A",
//             "salarystandardname": "软件开发工程师",
//             "salarysummoney": 5272,
//             "settersname": "赵子龙",
//             "bookername": null,
//             "checkername": null,
//             "booktime": null,
//             "checktime": null,
//             "changetime": null,
//             "basicsalary": 5000,
//             "trafficallowance": 500,
//             "lunchallowance": 500,
//             "commallowance": 200,
//             "endowmentins": 400,
//             "medicalins": 103,
//             "uneloymentins": 25,
//             "housingfund": 400,
//             "reviewopinion": null,
//             "changePersonname": null

function salarystandardnamewhenchange(salaryStandardName){
    $(salaryData['data']).each(function(){
        if(this.salarystandardname == salaryStandardName) {
            $("input[name = 'salarystandardid']").val(this.salarystandardid);
            $("input[name = 'settersname']").val(this.settersname);
            $("input[name = 'salarysummoney']").val(this.salarysummoney);
            $("input[name = 'basicsalary']").val(this.basicsalary);
            $("input[name = 'trafficallowance']").val(this.trafficallowance);
            $("input[name = 'lunchallowance']").val(this.lunchallowance);
            $("input[name = 'commallowance']").val(this.commallowance);
            $("input[name = 'endowmentins']").val(this.endowmentins);
            $("input[name = 'medicalins']").val(this.medicalins);
            $("input[name = 'uneloymentins']").val(this.uneloymentins);
            $("input[name = 'housingfund']").val(this.housingfund);
        }
    });

}


/*为页面加载点击添加事件*/
function loadBind(){
    /*为薪酬标准名称添加点击事件*/
    $("#salarystandardname").unbind("click");
    $("#salarystandardname").bind("click",function(){
        salarystandardnamewhenchange($("#salarystandardname").val());
    });

    /*为提交添加点击事件*/
    /*$("input[name = 'formsubmit']").unbind("click");
    $("input[name = 'formsubmit']").bind("click",function(){
        submitData();
    });*/

}



/*提交表单数据*/
